package controllers

import (
	"github.com/cihub/seelog"
	"github.com/gin-gonic/gin"
	"net/http"
	"test/models"
)

//post 详情
func PostGet(c *gin.Context) {

	id := c.Param("id")
	post, err := models.GetPostById(id)
	if err != nil || !post.IsPublished {
		Handle404(c)
		return
	}
	post.View++
	post.UpdateView()

	//PostAdd()

	seelog.Error("Post 详情页面")
	c.HTML(http.StatusOK, "post/detail.html", gin.H{
		"post": post,
	})
}

func PostAdd() {
	seelog.Info(models.CreatePost())
}
